package com.ruoyi.system.controller;

import com.ruoyi.common.core.domain.FileModel;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.system.domain.SysInvestorMsg;
import com.ruoyi.system.service.ISysInvestorMsgService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 投资信息Controller
 * 
 * @author paul
 * @date 2023-06-25
 */
@RestController
@RequestMapping("/msg")
public class SysInvestorMsgController extends BaseController
{
    @Autowired
    private ISysInvestorMsgService sysInvestorMsgService;

    /**
     * 查询投资信息列表
     */
//    @PreAuthorize("@ss.hasPermi('system:msg:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysInvestorMsg sysInvestorMsg)
    {
        startPage();
        List<SysInvestorMsg> list = sysInvestorMsgService.selectSysInvestorMsgList(sysInvestorMsg);
        return getDataTable(list);
    }

    /**
     * 导出投资信息列表
     */
//    @PreAuthorize("@ss.hasPermi('system:msg:export')")
    @Log(title = "投资信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysInvestorMsg sysInvestorMsg)
    {
        List<SysInvestorMsg> list = sysInvestorMsgService.selectSysInvestorMsgList(sysInvestorMsg);
        ExcelUtil<SysInvestorMsg> util = new ExcelUtil<SysInvestorMsg>(SysInvestorMsg.class);
        util.exportExcel(response, list, "投资信息数据");
    }

    /**
     * 获取投资信息详细信息
     */
//    @PreAuthorize("@ss.hasPermi('system:msg:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysInvestorMsgService.selectSysInvestorMsgById(id));
    }

    /**
     * 新增投资信息
     */
//    @PreAuthorize("@ss.hasPermi('system:msg:add')")
    @Log(title = "投资信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysInvestorMsg sysInvestorMsg)
    {
        return toAjax(sysInvestorMsgService.insertSysInvestorMsg(sysInvestorMsg));
    }

    /**
     * 修改投资信息
     */
//    @PreAuthorize("@ss.hasPermi('system:msg:edit')")
    @Log(title = "投资信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysInvestorMsg sysInvestorMsg)
    {
        return toAjax(sysInvestorMsgService.updateSysInvestorMsg(sysInvestorMsg));
    }

    /**
     * 删除投资信息
     */
//    @PreAuthorize("@ss.hasPermi('system:msg:remove')")
    @Log(title = "投资信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysInvestorMsgService.deleteSysInvestorMsgByIds(ids));
    }
}
